<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickpointerdevicehandler.cpp -->
  <title>PointerDeviceHandler QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >PointerDeviceHandler QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#properties">属性</a></li>
<li class="level1"><a href="#signals">信号</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">PointerDeviceHandler QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$PointerDeviceHandler-brief -->
<p>Abstract handler for pointer events with device-specific constraints. <a href="#details">更多...</a></p>
<!-- @@@PointerDeviceHandler -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick 2.12</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.10</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-pointerhandler.html">PointerHandler</a></p>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> 被继承：</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-multipointhandler.html">MultiPointHandler</a> and <a href="qml-qtquick-singlepointhandler.html">SinglePointHandler</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-pointerdevicehandler-members.html">所有成员的列表，包括继承成员</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">属性</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#acceptedButtons-prop">acceptedButtons</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#acceptedDevices-prop">acceptedDevices</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#acceptedModifiers-prop">acceptedModifiers</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#acceptedPointerTypes-prop">acceptedPointerTypes</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#active-prop">active</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#enabled-prop">enabled</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#grabPermissions-prop">grabPermissions</a></b></b> : flags</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#margin-prop">margin</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#parent-prop">parent</a></b></b> : Item</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#target-prop">target</a></b></b> : Item</li>
</ul>
<a name="signals"></a>
<h2 id="signals">信号</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#canceled-signal">canceled</a></b></b>(EventPoint <i>point</i>)</li>
<li class="fn"><b><b><a href="qml-qtquick-pointerdevicehandler.html#grabChanged-signal">grabChanged</a></b></b>(GrabTransition <i>transition</i>,  EventPoint <i>point</i>)</li>
</ul>
<!-- $$$PointerDeviceHandler-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p>An intermediate class (not registered as a QML type) for handlers which allow filtering based on device type, pointer type, or keyboard modifiers.</p>
<!-- @@@PointerDeviceHandler -->
<h2>属性文档</h2>
<!-- $$$acceptedButtons -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedButtons-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedButtons-prop"></a><span class="name">acceptedButtons</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The mouse buttons which can activate this Pointer Handler.</p>
<p>By default, this property is set to <a href="qml-qtquick-mouseevent.html#button-prop">Qt.LeftButton</a>. It can be set to an OR combination of mouse buttons, and will ignore events from other buttons.</p>
<p>For example, a control could be made to respond to left and right clicks in different ways, with two handlers:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
          <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;left clicked&quot;</span>)
      }
      <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
          <span class="name">acceptedButtons</span>: <span class="name">Qt</span>.<span class="name">RightButton</span>
          <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;right clicked&quot;</span>)
      }
  }

</pre>
<p><b>Note: </b>Tapping on a touchscreen or tapping the stylus on a graphics tablet emulates clicking the left mouse button. This behavior can be altered via <a href="qml-qtquick-pointerdevicehandler.html#acceptedDevices-prop">acceptedDevices</a> or <a href="qml-qtquick-pointerdevicehandler.html#acceptedPointerTypes-prop">acceptedPointerTypes</a>.</p></div></div><!-- @@@acceptedButtons -->
<br/>
<!-- $$$acceptedDevices -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedDevices-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedDevices-prop"></a><span class="name">acceptedDevices</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The types of pointing devices that can activate this Pointer Handler.</p>
<p>By default, this property is set to <a href="qml-qtquick-pointerdevice.html#type-prop">PointerDevice.AllDevices</a>. If you set it to an OR combination of device types, it will ignore events from non-matching devices.</p>
<p>For example, a control could be made to respond to mouse and stylus clicks in one way, and touchscreen taps in another way, with two handlers:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedDevices</span>: <span class="name">PointerDevice</span>.<span class="name">Mouse</span> <span class="operator">|</span> <span class="name">PointerDevice</span>.<span class="name">Stylus</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;clicked&quot;</span>)
     }
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedDevices</span>: <span class="name">PointerDevice</span>.<span class="name">TouchScreen</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;tapped&quot;</span>)
     }
  }

</pre>
</div></div><!-- @@@acceptedDevices -->
<br/>
<!-- $$$acceptedModifiers -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedModifiers-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedModifiers-prop"></a><span class="name">acceptedModifiers</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this property is set, it will require the given keyboard modifiers to be pressed in order to react to pointer events, and otherwise ignore them.</p>
<p>If this property is set to <code>Qt.KeyboardModifierMask</code> (the default value), then the <a href="qml-qtquick-pointerhandler.html">PointerHandler</a> ignores the modifier keys.</p>
<p>For example, an <a href="qml-qtquick-item.html">Item</a> could have two handlers of the same type, one of which is enabled only if the required keyboard modifiers are pressed:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedModifiers</span>: <span class="name">Qt</span>.<span class="name">ControlModifier</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;control-tapped&quot;</span>)
     }
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedModifiers</span>: <span class="name">Qt</span>.<span class="name">NoModifier</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;tapped&quot;</span>)
     }
  }

</pre>
</div></div><!-- @@@acceptedModifiers -->
<br/>
<!-- $$$acceptedPointerTypes -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="acceptedPointerTypes-prop">
<td class="tblQmlPropNode"><p>
<a name="acceptedPointerTypes-prop"></a><span class="name">acceptedPointerTypes</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The types of pointing instruments (finger, stylus, eraser, etc.) that can activate this Pointer Handler.</p>
<p>By default, this property is set to <a href="qml-qtquick-pointerdevice.html#pointerType-prop">PointerDevice.AllPointerTypes</a>. If you set it to an OR combination of device types, it will ignore events from non-matching events.</p>
<p>For example, a control could be made to respond to mouse, touch, and stylus clicks in some way, but delete itself if tapped with an eraser tool on a graphics tablet, with two handlers:</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
     <span class="name">id</span>: <span class="name">rect</span>
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedPointerTypes</span>: <span class="name">PointerDevice</span>.<span class="name">GenericPointer</span> <span class="operator">|</span> <span class="name">PointerDevice</span>.<span class="name">Finger</span> <span class="operator">|</span> <span class="name">PointerDevice</span>.<span class="name">Pen</span>
         <span class="name">onTapped</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;clicked&quot;</span>)
     }
     <span class="type"><a href="qml-qtquick-taphandler.html">TapHandler</a></span> {
         <span class="name">acceptedPointerTypes</span>: <span class="name">PointerDevice</span>.<span class="name">Eraser</span>
         <span class="name">onTapped</span>: <span class="name">rect</span>.<span class="name">destroy</span>()
     }
  }

</pre>
</div></div><!-- @@@acceptedPointerTypes -->
<br/>
<!-- $$$active -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="active-prop">
<td class="tblQmlPropNode"><p>
<a name="active-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">active</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This holds true whenever this Input Handler has taken sole responsibility for handing one or more EventPoints, by successfully taking an exclusive grab of those points. This means that it is keeping its properties up-to-date according to the movements of those Event Points and actively manipulating its <a href="qml-qtquick-pointerdevicehandler.html#target-prop">target</a> (if any).</p>
</div></div><!-- @@@active -->
<br/>
<!-- $$$enabled -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="enabled-prop">
<td class="tblQmlPropNode"><p>
<a name="enabled-prop"></a><span class="name">enabled</span> : <span class="type"><a href="../qtqml/qml-bool.html">bool</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If a <a href="qml-qtquick-pointerhandler.html">PointerHandler</a> is disabled, it will reject all events and no signals will be emitted.</p>
</div></div><!-- @@@enabled -->
<br/>
<!-- $$$grabPermissions -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="grabPermissions-prop">
<td class="tblQmlPropNode"><p>
<a name="grabPermissions-prop"></a><span class="name">grabPermissions</span> : <span class="type">flags</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property specifies the permissions when this handler's logic decides to take over the exclusive grab, or when it is asked to approve grab takeover or cancellation by another handler.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>PointerHandler.TakeOverForbidden</code></td><td class="topAlign">This handler neither takes from nor gives grab permission to any type of Item or Handler.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.CanTakeOverFromHandlersOfSameType</code></td><td class="topAlign">This handler can take the exclusive grab from another handler of the same class.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.CanTakeOverFromHandlersOfDifferentType</code></td><td class="topAlign">This handler can take the exclusive grab from any kind of handler.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.CanTakeOverFromAnything</code></td><td class="topAlign">This handler can take the exclusive grab from any type of Item or Handler.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByHandlersOfSameType</code></td><td class="topAlign">This handler gives permission for another handler of the same class to take the grab.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByHandlersOfDifferentType</code></td><td class="topAlign">This handler gives permission for any kind of handler to take the grab.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByItems</code></td><td class="topAlign">This handler gives permission for any kind of Item to take the grab.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesCancellation</code></td><td class="topAlign">This handler will allow its grab to be set to null.</td></tr>
<tr><td class="topAlign"><code>PointerHandler.ApprovesTakeOverByAnything</code></td><td class="topAlign">This handler gives permission for any any type of Item or Handler to take the grab.</td></tr>
</table></div>
<p>The default is <code>PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType | PointerHandler.ApprovesTakeOverByAnything</code> which allows most takeover scenarios but avoids e.g&#x2e; two PinchHandlers fighting over the same touchpoints.</p>
</div></div><!-- @@@grabPermissions -->
<br/>
<!-- $$$margin -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="margin-prop">
<td class="tblQmlPropNode"><p>
<a name="margin-prop"></a><span class="name">margin</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The margin beyond the bounds of the <a href="qml-qtquick-pointerdevicehandler.html#parent-prop">parent</a> item within which an event point can activate this handler. For example, on a <a href="qml-qtquick-pinchhandler.html">PinchHandler</a> where the <a href="qml-qtquick-pointerdevicehandler.html#target-prop">target</a> is also the <code>parent</code>, it's useful to set this to a distance at least half the width of a typical user's finger, so that if the <code>parent</code> has been scaled down to a very small size, the pinch gesture is still possible. Or, if a <a href="qml-qtquick-taphandler.html">TapHandler</a>-based button is placed near the screen edge, it can be used to comply with Fitts's Law: react to mouse clicks at the screen edge even though the button is visually spaced away from the edge by a few pixels.</p>
<p>The default value is 0.</p>
<p class="centerAlign"><img src="images/pointerHandlerMargin.png" alt="" /></p></div></div><!-- @@@margin -->
<br/>
<!-- $$$parent -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="parent-prop">
<td class="tblQmlPropNode"><p>
<a name="parent-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">parent</span> : <span class="type"><a href="qml-qtquick-item.html">Item</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The <a href="qml-qtquick-item.html">Item</a> which is the scope of the handler; the Item in which it was declared. The handler will handle events on behalf of this Item, which means a pointer event is relevant if at least one of its event points occurs within the Item's interior. Initially <a href="qml-qtquick-pointerdevicehandler.html#target-prop">target()</a> is the same, but it can be reassigned.</p>
<p><b>请参考 </b><a href="qml-qtquick-pointerdevicehandler.html#target-prop">target</a> 和 <a href="../qtcore/qobject.html#parent">QObject::parent()</a>。</p>
</div></div><!-- @@@parent -->
<br/>
<!-- $$$target -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="target-prop">
<td class="tblQmlPropNode"><p>
<a name="target-prop"></a><span class="name">target</span> : <span class="type"><a href="qml-qtquick-item.html">Item</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The Item which this handler will manipulate.</p>
<p>By default, it is the same as the <a href="qml-qtquick-pointerdevicehandler.html#parent-prop">parent</a>, the Item within which the handler is declared. However, it can sometimes be useful to set the target to a different Item, in order to handle events within one item but manipulate another; or to <code>null</code>, to disable the default behavior and do something else instead.</p>
</div></div><!-- @@@target -->
<br/>
<h2>Signal Documentation</h2>
<!-- $$$canceled -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="canceled-signal">
<td class="tblQmlFuncNode"><p>
<a name="canceled-signal"></a><span class="name">canceled</span>(<span class="type"><a href="qml-qtquick-eventpoint.html">EventPoint</a></span> <i>point</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>If this handler has already grabbed the given <i>point</i>, this signal is emitted when the grab is stolen by a different Pointer Handler or Item.</p>
</div></div><!-- @@@canceled -->
<br/>
<!-- $$$grabChanged -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="grabChanged-signal">
<td class="tblQmlFuncNode"><p>
<a name="grabChanged-signal"></a><span class="name">grabChanged</span>(<span class="type">GrabTransition</span> <i>transition</i>,  <span class="type"><a href="qml-qtquick-eventpoint.html">EventPoint</a></span> <i>point</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the grab has changed in some way which is relevant to this handler.</p>
<p>The <i>transition</i> (verb) tells what happened. The <i>point</i> (object) is the point that was grabbed or ungrabbed.</p>
</div></div><!-- @@@grabChanged -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
